import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class Conexao {
	public static void main(String[] args) {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://localhost:3306/t2tidb";
			Connection con = DriverManager.getConnection(url, "t2ti", "123");
			System.out.println("Con: "+con);
			Statement statement = con.createStatement();
			
			/*statement.executeUpdate("Insert into Clientes (rg, nome) values (5, 'Gabriel')");*/ //Adiciona no banco
			
			
			ResultSet rs = statement.executeQuery("Select * from Clientes");
			if(rs.first()){
				do{
					System.out.println("Nome: "+rs.getString("nome"));
					System.out.println("Rg: "+rs.getString("rg"));
					System.out.println(" ");
				}while(rs.next());
			}
			
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
